<template>
	<view class="template-movie tn-safe-area-inset-bottom">
		<!-- 顶部自定义导航 -->
		<!-- <tn-nav-bar fixed alpha customBack>
      <view slot="back" class='tn-custom-nav-bar__back'
        @click="goBack">
        <text class='icon tn-icon-left'></text>
        <text class='icon tn-icon-home-capsule-fill'></text>
      </view>
    </tn-nav-bar> -->

		<!-- 顶部自定义导航 -->
		<tn-nav-bar fixed :isBack="false" :bottomShadow="false" backgroundColor="none">
			<view class="custom-nav tn-flex tn-flex-col-center tn-flex-row-left">
				<!-- 图标logo -->
				<view class="custom-nav__back">
					<view class="logo-pic tn-shadow-blur"
						style="background-image:url('https://imgcdn.tutudati.com/Snipaste_2024-03-29_19-24-17.png')">
						<view class="logo-image">
						</view>
					</view>
					<!-- <view class="tn-icon-left"></view> -->
				</view>
				<!-- 搜索框 -->
				<view class="custom-nav__search tn-flex tn-flex-col-center tn-flex-row-center ">
					<view class="custom-nav__search__box tn-flex tn-flex-col-center tn-flex-row-left">
						<view class="custom-nav__search__icon tn-icon-search"></view>
						<view class="custom-nav__search__text tn-padding-left-xs">搜点什么好呢?</view>
					</view>
				</view>
			</view>
		</tn-nav-bar>



		<view class="top-backgroup">
			<image src='https://imgcdn.tutudati.com/tutuxiaotuvideo1111.jpg' mode='widthFix' class='backgroud-image'>
			</image>
		</view>


		<view class="" style="margin: -270rpx 0 120rpx 0;">
			<tn-notice-bar :show="closeNoticeShow" :list="noticeList" :closeBtn="true"
				@close="closeNoticeShow = false"></tn-notice-bar>
			<view class="tn-margin-top-sm">
				<tn-sticky :offsetTop="10" :customNavHeight="vuex_custom_bar_height">
					<tn-tabs :list="videoTag" :current="current" activeColor="#000" name="title" bold="true" :fontSize="32"
						:badgeOffset="[20, 50]" @change="tabChange"></tn-tabs>
				</tn-sticky>
			</view>
		</view>

		<swiper class="card-swiper" :circular="true" :autoplay="true" duration="500" interval="5000"
			previous-margin="200rpx" next-margin="200rpx" @change="cardSwiper" style="margin-top: -80rpx;">
			<swiper-item v-for="(item,index) in swiperList" :key="index" :class="cardCur==index?'cur':''" @click="playVideo(item)">
				<view class="swiper-item image-banner">
					<image :src="item.cover" mode="aspectFill"></image>
				</view>
				<view class="swiper-item-text">
					<view class="tn-text-xxl tn-text-bold">{{item.title || ""}}</view>
					<!-- <view class="tn-text-sm tn-text-bold tn-padding-top-xs">{{item.text}}</view> -->
				</view>
			</swiper-item>
		</swiper>
		<view class="indication">
			<block v-for="(item,index) in swiperList" :key="index">
				<view class="spot" :class="cardCur==index?'active':''"></view>
			</block>
		</view>

		<!-- 方式16 start-->
		<view class="tn-flex tn-flex-wrap tn-margin-top-xl tn-padding-sm">
			<block v-for="(item, index) in videoList" :key="index">
				<view class="" style="width: 33.3%;" @click="playVideo(item)">
					<view class="tn-flex tn-flex-direction-column tn-flex-row-center tn-flex-col-center ">
						<view class="tn-radius tn-padding-sm">
							<view class="image-pic" :style="'background-image:url('+ item.cover +')'">
								<view class="image-movie">
								</view>
							</view>
							<view class="tn-text-center tn-text-bold tn-padding-top-xs">{{item.title || ""}}</view>
							<!-- <view class="tn-text-center tn-text-xs tn-color-gray--dark tn-padding-top-xs">{{item.text}}</view> -->
						</view>
					</view>
				</view>
			</block>
		</view>
		<!-- 方式16 end-->

		<!-- 底部tabbar start-->
	<!-- 	<view class="tabbar footerfixed">
			<view class="action bar-left">
				<view class="bar-icon">
					<view class="tn-icon-discover-fill tn-color-aquablue">
					</view> -->
					<!-- <image class="" src='https://resource.tuniaokj.com/images/tabbar/home_tnnew.png'></image> -->
				<!-- </view>
				<view class="tn-color-black">首页</view>
			</view> -->
			<!-- <view class="action bar-center">
				<view class="bar-circle tn-shadow-blur">
					<view class="tn-icon-vip-fill tn-color-white">
					</view> -->
					<!-- <image class="" src='https://resource.tuniaokj.com/images/tabbar/information_tn.png'></image> -->
				<!-- </view> -->
				<!-- <view class="tn-color-gray">发布</view> -->
			<!-- </view> -->
	<!-- 		<view class="action bar-right" @click="playHistory">
				<view class="bar-icon">
					<view class="tn-icon-eye-fill tn-color-gray--dark">
					</view>
					 <image class="" src='https://resource.tuniaokj.com/images/tabbar/my_tn.png'></image> -->
				<!-- </view>
				<view class="tn-color-gray">历史</view>
			</view>
		</view>
		<view class="tn-padding-xl"></view> -->

		<!-- 回到首页悬浮按钮-->
		<block v-if="showTopBtn">
			<nav-index-button></nav-index-button>
		</block>
	</view>
</template>

<script>
	import template_page_mixin from '@/libs/mixin/template_page_mixin.js'
	import NavIndexButton from '@/libs/components/nav-index-button.vue'
	import { tagList, videoList } from "@/utils/api/video.js"
	import { noticeList } from "@/utils/api/sys.js"
	export default {
		name: 'TemplateMovie',
		mixins: [template_page_mixin],
		components: {
			NavIndexButton
		},
		data() {
			return {
				showTopBtn: false,
				noticeList: [],
				closeNoticeShow: true,
				cardCur: 0,
				swiperList: [],
				current: 0,
				videoTag: [],
				videoList: [],
				videoSearchWhere: {
					page: 1,
					size: 20,
					is_hot:0,
					is_rec: 0,
					tag_uid: "",
				},
			}
		},
		onLoad() {
			this.getVideoList()
			this.getVideoTagList()
			this.getNoticeList()
			this.getRecVideoList()
		},
		onReachBottom() {
			this.videoSearchWhere.page = this.videoSearchWhere.page + 1
			this.getVideoList()
		},
		onPageScroll(e) {
			this.closeNoticeShow = false
			e.scrollTop > 2000 ? this.showTopBtn = true : this.showTopBtn = false
		},
		methods: {
			playHistory() {
				this.$func.showToast("努力开发中")
			},
			getNoticeList() {
				noticeList({position: "video-home"}).then(res => { this.noticeList = res.data })
			},
			getVideoTagList() {
				tagList().then(res => { this.videoTag = res.data })
			},
			getRecVideoList() {
				videoList({ is_rec: 1 }).then(res => { this.swiperList = res.data.items })
			},
			getVideoList() {
				uni.showLoading({
					title: "努力加载中",
					mask: true,
				})
				videoList(this.videoSearchWhere).then(res => {
					this.videoList.push(...res.data.items)
					this.videoSearchWhere.page = res.data.page
					uni.hideLoading()
				})
			},
			playVideo(item) {
				uni.navigateTo({
					url: "/pageVideo/play/index?uid=" + item.uid + "&tag_uid=" + item.tag_uid
				})
			},
			cardSwiper(e) {
				this.cardCur = e.detail.current
			},
			tabChange(index) {
				this.current = index
				this.videoSearchWhere.tag_uid = this.videoTag[index].uid
				this.videoSearchWhere.page = 1
				this.getVideoList()
				this.videoList = []
			}
		}
	}
</script>

<style lang="scss" scoped>
	@import '@/scss/custom_nav_bar.scss';

	/* 自定义导航栏内容 start */
	.custom-nav {
		height: 100%;

		&__back {
			margin: auto 5rpx;
			font-size: 40rpx;
			margin-right: 10rpx;
			margin-left: 30rpx;
			flex-basis: 5%;
		}

		&__search {
			flex-basis: 60%;
			width: 100%;
			height: 100%;

			&__box {
				width: 100%;
				height: 70%;
				padding: 10rpx 0;
				margin: 0 30rpx;
				border-radius: 60rpx 60rpx 0 60rpx;
				font-size: 24rpx;
				background-color: rgba(255, 255, 255, 0.5);
			}

			&__icon {
				padding-right: 10rpx;
				margin-left: 20rpx;
				font-size: 30rpx;
			}

			&__text {
				color: #080808;
			}
		}
	}

	.logo-image {
		width: 65rpx;
		height: 65rpx;
		position: relative;
	}

	.logo-pic {
		background-size: cover;
		background-repeat: no-repeat;
		// background-attachment:fixed;
		background-position: top;
		border-radius: 50%;
	}

	/* 自定义导航栏内容 end */
	/* 顶部背景图 start */
	.top-backgroup {
		height: 450rpx;
		z-index: -1;

		.backgroud-image {
			width: 100%;
			height: 667rpx;
			// z-index: -1;
		}
	}

	/* 顶部背景图 end */
	/* 轮播样机样式 start*/
	.card-swiper {
		height: 560rpx !important;
		border-radius: 0 0 50% 50%/0 0 10% 10%;
		overflow: hidden;
	}

	.card-swiper swiper-item {
		width: 350rpx !important;
		// left: 200rpx;
		box-sizing: border-box;
		padding: 0rpx 15rpx 20rpx 15rpx;
		overflow: initial;
	}

	.card-swiper swiper-item .swiper-item {
		width: 100%;
		display: block;
		height: 100%;
		border-radius: 25rpx;
		transform: scale(0.9) translate(0rpx, 60rpx);
		transition: all 0.2s ease-in 0s;
		overflow: hidden;
	}

	.card-swiper swiper-item.cur .swiper-item {
		transform: none;
		transition: all 0.2s ease-in 0s;
	}

	.card-swiper swiper-item .swiper-item-text {
		margin-top: -120rpx;
		width: 100%;
		display: block;
		height: 50%;
		border-radius: 10rpx;
		transform: translate(0rpx, 0rpx) scale(0.7, 0.7);
		transition: all 0.4s ease 0s;
		overflow: hidden;
		color: #000000;
		opacity: 0;
	}

	.card-swiper swiper-item.cur .swiper-item-text {
		margin-top: -150rpx;
		padding-left: 30rpx;
		width: 100%;
		transform: translate(-20rpx, 20rpx) scale(0.9, 0.9);
		transition: all 0.4s ease 0s;
		color: #FFFFFF;
		text-shadow: 0rpx 10rpx 30rpx rgba(0, 0, 0, 0.3);
		opacity: 1;
	}

	.image-banner {
		display: flex;
		align-items: center;
		justify-content: center;
		// box-shadow: 0rpx 30rpx 60rpx 0rpx rgba(116,10,250, 0.06);
	}

	.image-banner image {
		width: 100%;
		height: 100%;
	}

	/* 轮播指示点 start*/
	.indication {
		z-index: 9999;
		width: 100%;
		height: 36rpx;
		position: absolute;
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: center;
	}

	.spot {
		background-color: #000;
		opacity: 0;
		width: 10rpx;
		height: 10rpx;
		border-radius: 20rpx;
		margin: 0 8rpx !important;
		top: -80rpx;
		position: relative;
	}

	.spot.active {
		opacity: 0;
		width: 30rpx;
		background-color: #000;
	}

	/* 效果布局 start*/
	.image-movie {
		width: 200rpx;
		height: 300rpx;
		font-size: 40rpx;
		font-weight: 300;
		position: relative;
	}

	.image-pic {
		height: 100%;
		background-size: cover;
		background-repeat: no-repeat;
		// background-attachment:fixed;
		background-position: top;
		border-radius: 10rpx;
	}

	/* 底部tabbar start*/
	.footerfixed {
		position: fixed;
		width: 100%;
		bottom: 0;
		z-index: 999;
		// box-shadow: 0rpx 0rpx 30rpx 0rpx rgba(0, 0, 0, 0.07);
	}

	.tabbar {
		display: flex;
		align-items: center;
		min-height: 110rpx;
		justify-content: space-between;
		padding: 0;
		height: calc(110rpx + env(safe-area-inset-bottom) / 2);
		padding-bottom: calc(env(safe-area-inset-bottom) / 2);
	}

	.tabbar .action {
		font-size: 22rpx;
		position: relative;
		flex: 1;
		text-align: center;
		padding: 0;
		display: block;
		height: auto;
		line-height: 1;
		padding: 50rpx;
		overflow: initial;
	}

	.bar-left {
		background-color: #FFFFFF;
		border-radius: 0rpx 95% 0rpx 0rpx / 0rpx 94% 0rpx 0rpx;
		box-shadow: 0rpx 0rpx 30rpx 0rpx rgba(0, 0, 0, 0.07);
	}

	.bar-center {
		animation: suspension 3s ease-in-out infinite;
	}

	@keyframes suspension {

		0%,
		100% {
			transform: translateY(0);
		}

		50% {
			transform: translateY(-0.8rem);
		}
	}

	.bar-right {
		background-color: #FFFFFF;
		border-radius: 95% 0rpx 0rpx 0rpx / 94% 0rpx 0rpx 0rpx;
		box-shadow: 0rpx 0rpx 30rpx 0rpx rgba(0, 0, 0, 0.07);
	}

	.tabbar .action .bar-icon {
		width: 100rpx;
		position: relative;
		display: block;
		height: auto;
		margin: 0 auto 10rpx;
		text-align: center;
		font-size: 42rpx;
		// line-height: 50rpx;
	}

	.tabbar .action .bar-icon image {
		width: 50rpx;
		height: 50rpx;
		display: inline-block;
	}

	.tabbar .action .bar-circle {
		position: relative;
		display: block;
		margin: -30rpx auto 20rpx;
		text-align: center;
		font-size: 52rpx;
		line-height: 90rpx;
		background-color: #3646FF;
		width: 90rpx !important;
		height: 90rpx !important;
		overflow: hidden;
		border-radius: 50%;
		box-shadow: 0rpx 0rpx 20rpx 0rpx rgba(54, 70, 255, 0.5);
	}

	.tabbar .action .bar-circle image {
		width: 60rpx;
		height: 60rpx;
		display: inline-block;
		margin: 15rpx auto 15rpx;
	}
</style>